{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Executing an Individual Task (Electron)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Prerequisites\n",
    "\n",
    "[Start](./covalent_cli.rst) the Covalent services.\n",
    "\n",
    "### Procedure\n",
    "\n",
    "To execute an individual electron:\n",
    "\n",
    "1. Decorate it with a `@lattice` decorator as shown below. (Note that the `@lattice` decorator is applied \"atop\" or \"around\" the task's `@electron` decorator.)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import covalent as ct\n",
    "\n",
    "@ct.lattice\n",
    "@ct.electron\n",
    "def product(x, y):\n",
    "    return x * y"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "2. Dispatch the lattice:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "7e7c1440-8beb-4f3f-9252-9b43d508bf61\n"
     ]
    }
   ],
   "source": [
    "dispatch_id = ct.dispatch(product)(2, 3)\n",
    "print(dispatch_id)"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Executing the individual electron returns a dispatch ID that can be used to query the electron's computation result. This is a useful technique for [testing an individual electron](../coding/test_electron.ipynb).\n",
    "\n",
    "### See Also\n",
    "\n",
    "[Testing an Electron](../coding/test_electron.ipynb)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  },
  "vscode": {
   "interpreter": {
    "hash": ""
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
